3 class WebInstaller
extends Installer
{
4 /** WebRequest object */
7 /** Cached session array */
10 /** Captured PHP error text. Temporary.
15 * The main sequence of page names. These will be displayed in turn.
18 * * Add a config-page-<name> message
19 * * Add a WebInstaller_<name> class
21 public $pageSequence = array(
34 * Out of sequence pages, selectable by the user at any time.
36 public $otherPages = array(
41 'UpgradeDoc', // Can't use Upgrade due to Upgrade step
45 * Array of pages which have declared that they have been submitted, have validated
46 * their input, and need no further processing.
51 * List of "skipped" pages. These are pages that will automatically continue
52 * to the next page on any GET request. To avoid breaking the "back" button,
53 * they need to be skipped during a back operation.
58 * Flag indicating that session data may have been lost.
60 public $showSessionWarning = false;
65 public $currentPageName;
68 public function __construct( $request ) {
69 parent
::__construct();
70 $this->output
= new WebInstallerOutput( $this );
71 $this->request
= $request;
77 * @param $session Array: initial session array
79 * @return Array: new session array
81 public function execute( $session ) {
82 $this->session
= $session;
83 if ( isset( $session['settings'] ) ) {
84 $this->settings
= $session['settings'] +
$this->settings
;
87 $this->setupLanguage();
89 if( $this->getVar( '_InstallDone' ) && $this->request
->getVal( 'localsettings' ) )
91 $ls = new LocalSettingsGenerator( $this );
92 $this->request
->response()->header('Content-type: text/plain');
93 $this->request
->response()->header(
94 'Content-Disposition: attachment; filename="LocalSettings.php"'
97 return $this->session
;
100 if ( isset( $session['happyPages'] ) ) {
101 $this->happyPages
= $session['happyPages'];
103 $this->happyPages
= array();
105 if ( isset( $session['skippedPages'] ) ) {
106 $this->skippedPages
= $session['skippedPages'];
108 $this->skippedPages
= array();
110 $lowestUnhappy = $this->getLowestUnhappy();
112 # Special case for Creative Commons partner chooser box
113 if ( $this->request
->getVal( 'SubmitCC' ) ) {
114 $page = $this->getPageByName( 'Options' );
115 $this->output
->useShortHeader();
117 return $this->finish();
119 if ( $this->request
->getVal( 'ShowCC' ) ) {
120 $page = $this->getPageByName( 'Options' );
121 $this->output
->useShortHeader();
122 $this->output
->addHTML( $page->getCCDoneBox() );
123 return $this->finish();
127 $pageName = $this->request
->getVal( 'page' );
129 if ( in_array( $pageName, $this->otherPages
) ) {
132 $page = $this->getPageByName( $pageName );
135 if ( !$pageName ||
!in_array( $pageName, $this->pageSequence
) ) {
136 $pageId = $lowestUnhappy;
138 $pageId = array_search( $pageName, $this->pageSequence
);
141 # If necessary, move back to the lowest-numbered unhappy page
142 if ( $pageId > $lowestUnhappy ) {
143 $pageId = $lowestUnhappy;
144 if ( $lowestUnhappy == 0 ) {
145 # Knocked back to start, possible loss of session data
146 $this->showSessionWarning
= true;
149 $pageName = $this->pageSequence
[$pageId];
150 $page = $this->getPageByName( $pageName );
153 # If a back button was submitted, go back without submitting the form data
154 if ( $this->request
->wasPosted() && $this->request
->getBool( 'submit-back' ) ) {
155 if ( $this->request
->getVal( 'lastPage' ) ) {
156 $nextPage = $this->request
->getVal( 'lastPage' );
157 } elseif ( $pageId !== false ) {
159 # Skip the skipped pages
160 $nextPageId = $pageId;
163 $nextPage = $this->pageSequence
[$nextPageId];
164 } while( isset( $this->skippedPages
[$nextPage] ) );
166 $nextPage = $this->pageSequence
[$lowestUnhappy];
168 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
169 return $this->finish();
173 $this->currentPageName
= $page->getName();
174 $this->startPageWrapper( $pageName );
175 $localSettings = $this->getLocalSettingsStatus();
176 if( !$localSettings->isGood() ) {
177 $this->showStatusBox( $localSettings );
180 $result = $page->execute();
182 $this->endPageWrapper();
184 if ( $result == 'skip' ) {
185 # Page skipped without explicit submission
186 # Skip it when we click "back" so that we don't just go forward again
187 $this->skippedPages
[$pageName] = true;
188 $result = 'continue';
190 unset( $this->skippedPages
[$pageName] );
193 # If it was posted, the page can request a continue to the next page
194 if ( $result === 'continue' && !$this->output
->headerDone() ) {
195 if ( $pageId !== false ) {
196 $this->happyPages
[$pageId] = true;
198 $lowestUnhappy = $this->getLowestUnhappy();
200 if ( $this->request
->getVal( 'lastPage' ) ) {
201 $nextPage = $this->request
->getVal( 'lastPage' );
202 } elseif ( $pageId !== false ) {
203 $nextPage = $this->pageSequence
[$pageId +
1];
205 $nextPage = $this->pageSequence
[$lowestUnhappy];
207 if ( array_search( $nextPage, $this->pageSequence
) > $lowestUnhappy ) {
208 $nextPage = $this->pageSequence
[$lowestUnhappy];
210 $this->output
->redirect( $this->getUrl( array( 'page' => $nextPage ) ) );
212 return $this->finish();
215 public function getLowestUnhappy() {
216 if ( count( $this->happyPages
) == 0 ) {
219 return max( array_keys( $this->happyPages
) ) +
1;
224 * Start the PHP session. This may be called before execute() to start the PHP session.
226 public function startSession() {
227 $sessPath = $this->getSessionSavePath();
228 if( $sessPath != '' ) {
229 if( strval( ini_get( 'open_basedir' ) ) != '' ) {
230 // we need to skip the following check when open_basedir is on.
231 // The session path probably *wont* be writable by the current
232 // user, and telling them to change it is bad. Bug 23021.
233 } elseif( !is_dir( $sessPath ) ||
!is_writeable( $sessPath ) ) {
234 $this->showError( 'config-session-path-bad', $sessPath );
238 // If the path is unset it'll default to some system bit, which *probably* is ok...
239 // not sure how to actually get what will be used.
241 if( wfIniGetBool( 'session.auto_start' ) ||
session_id() ) {
246 $this->phpErrors
= array();
247 set_error_handler( array( $this, 'errorHandler' ) );
249 restore_error_handler();
250 if ( $this->phpErrors
) {
251 $this->showError( 'config-session-error', $this->phpErrors
[0] );
258 * Get the value of session.save_path
260 * Per http://www.php.net/manual/en/session.configuration.php#ini.session.save-path,
261 * this might have some additional preceding parts which need to be
266 private function getSessionSavePath() {
267 $path = ini_get( 'session.save_path' );
268 $path = ltrim( substr( $path, strrpos( $path, ';' ) ), ';');
274 * Show an error message in a box. Parameters are like wfMsg().
276 public function showError( $msg /*...*/ ) {
277 $args = func_get_args();
278 array_shift( $args );
279 $args = array_map( 'htmlspecialchars', $args );
280 $msg = wfMsgReal( $msg, $args, false, false, false );
281 $this->output
->addHTML( $this->getErrorBox( $msg ) );
285 * Temporary error handler for session start debugging.
287 public function errorHandler( $errno, $errstr ) {
288 $this->phpErrors
[] = $errstr;
292 * Clean up from execute()
294 public function finish() {
295 $this->output
->output();
296 $this->session
['happyPages'] = $this->happyPages
;
297 $this->session
['skippedPages'] = $this->skippedPages
;
298 $this->session
['settings'] = $this->settings
;
299 return $this->session
;
303 * Get a URL for submission back to the same script.
305 public function getUrl( $query = array() ) {
306 $url = $this->request
->getRequestURL();
307 # Remove existing query
308 $url = preg_replace( '/\?.*$/', '', $url );
310 $url .= '?' . wfArrayToCGI( $query );
316 * Get a WebInstallerPage from the main sequence, by ID.
318 public function getPageById( $id ) {
319 $pageName = $this->pageSequence
[$id];
320 $pageClass = 'WebInstaller_' . $pageName;
321 return new $pageClass( $this );
325 * Get a WebInstallerPage by name.
327 public function getPageByName( $pageName ) {
328 $pageClass = 'WebInstaller_' . $pageName;
329 return new $pageClass( $this );
333 * Get a session variable.
335 public function getSession( $name, $default = null ) {
336 if ( !isset( $this->session
[$name] ) ) {
339 return $this->session
[$name];
344 * Set a session variable.
346 public function setSession( $name, $value ) {
347 $this->session
[$name] = $value;
351 * Get the next tabindex attribute value.
353 public function nextTabIndex() {
354 return $this->tabIndex++
;
358 * Initializes language-related variables.
360 public function setupLanguage() {
361 global $wgLang, $wgContLang, $wgLanguageCode;
362 if ( $this->getSession( 'test' ) === null && !$this->request
->wasPosted() ) {
363 $wgLanguageCode = $this->getAcceptLanguage();
364 $wgLang = $wgContLang = Language
::factory( $wgLanguageCode );
365 $this->setVar( 'wgLanguageCode', $wgLanguageCode );
366 $this->setVar( '_UserLang', $wgLanguageCode );
368 $wgLanguageCode = $this->getVar( 'wgLanguageCode' );
369 $wgLang = Language
::factory( $this->getVar( '_UserLang' ) );
370 $wgContLang = Language
::factory( $wgLanguageCode );
375 * Retrieves MediaWiki language from Accept-Language HTTP header.
377 public function getAcceptLanguage() {
378 global $wgLanguageCode;
380 $mwLanguages = Language
::getLanguageNames();
381 $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
382 foreach ( explode( ';', $langs ) as $splitted ) {
383 foreach ( explode( ',', $splitted ) as $lang ) {
384 $lang = trim( strtolower( $lang ) );
385 if ( $lang == '' ||
$lang[0] == 'q' ) {
388 if ( isset( $mwLanguages[$lang] ) ) {
391 $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang );
392 if ( $lang != '' && isset( $mwLanguages[$lang] ) ) {
397 return $wgLanguageCode;
401 * Called by execute() before page output starts, to show a page list.
403 public function startPageWrapper( $currentPageName ) {
404 $s = "<div class=\"config-page-wrapper\">\n" .
405 "<div class=\"config-page-list\"><ul>\n";
407 foreach ( $this->pageSequence
as $id => $pageName ) {
408 $happy = !empty( $this->happyPages
[$id] );
409 $s .= $this->getPageListItem( $pageName,
410 $happy ||
$lastHappy == $id - 1, $currentPageName );
415 $s .= "</ul><br/><ul>\n";
416 foreach ( $this->otherPages
as $pageName ) {
417 $s .= $this->getPageListItem( $pageName, true, $currentPageName );
419 $s .= "</ul></div>\n". // end list pane
420 "<div class=\"config-page\">\n" .
421 Xml
::element( 'h2', array(),
422 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) );
424 $this->output
->addHTMLNoFlush( $s );
428 * Get a list item for the page list.
430 public function getPageListItem( $pageName, $enabled, $currentPageName ) {
431 $s = "<li class=\"config-page-list-item\">";
432 $name = wfMsg( 'config-page-' . strtolower( $pageName ) );
434 $query = array( 'page' => $pageName );
435 if ( !in_array( $pageName, $this->pageSequence
) ) {
436 if ( in_array( $currentPageName, $this->pageSequence
) ) {
437 $query['lastPage'] = $currentPageName;
439 $link = Xml
::element( 'a',
441 'href' => $this->getUrl( $query )
446 $link = htmlspecialchars( $name );
448 if ( $pageName == $currentPageName ) {
449 $s .= "<span class=\"config-page-current\">$link</span>";
454 $s .= Xml
::element( 'span',
456 'class' => 'config-page-disabled'
466 * Output some stuff after a page is finished.
468 public function endPageWrapper() {
469 $this->output
->addHTMLNoFlush(
471 "<br style=\"clear:both\"/>\n" .
476 * Get HTML for an error box with an icon.
478 * @param $text String: wikitext, get this with wfMsgNoTrans()
480 public function getErrorBox( $text ) {
481 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
485 * Get HTML for a warning box with an icon.
487 * @param $text String: wikitext, get this with wfMsgNoTrans()
489 public function getWarningBox( $text ) {
490 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
494 * Get HTML for an info box with an icon.
496 * @param $text String: wikitext, get this with wfMsgNoTrans()
497 * @param $icon String: icon name, file in skins/common/images
498 * @param $class String: additional class name to add to the wrapper div
500 public function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
502 "<div class=\"config-info $class\">\n" .
503 "<div class=\"config-info-left\">\n" .
506 'src' => '../skins/common/images/' . $icon,
507 'alt' => wfMsg( 'config-information' ),
511 "<div class=\"config-info-right\">\n" .
512 $this->parse( $text ) . "\n" .
514 "<div style=\"clear: left;\"></div>\n" .
520 * Get small text indented help for a preceding form field.
521 * Parameters like wfMsg().
523 public function getHelpBox( $msg /*, ... */ ) {
524 $args = func_get_args();
525 array_shift( $args );
526 $args = array_map( 'htmlspecialchars', $args );
527 $text = wfMsgReal( $msg, $args, false, false, false );
528 $html = $this->parse( $text, true );
529 $id = $this->helpId++
;
530 $alt = wfMsg( 'help' );
533 "<div class=\"config-help-wrapper\">\n" .
534 "<div class=\"config-help-message\">\n" .
537 "<div class=\"config-show-help\">\n" .
539 wfMsgHtml( 'config-show-help' ) .
541 "<div class=\"config-hide-help\">\n" .
543 wfMsgHtml( 'config-hide-help' ) .
544 "</a></div>\n</div>\n";
550 public function showHelpBox( $msg /*, ... */ ) {
551 $args = func_get_args();
552 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args );
553 $this->output
->addHTML( $html );
557 * Show a short informational message.
558 * Output looks like a list.
560 public function showMessage( $msg /*, ... */ ) {
561 $args = func_get_args();
562 array_shift( $args );
563 $html = '<div class="config-message">' .
564 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
566 $this->output
->addHTML( $html );
570 * Label a control by wrapping a config-input div around it and putting a
573 public function label( $msg, $forId, $contents ) {
574 if ( strval( $msg ) == '' ) {
575 $labelText = ' ';
577 $labelText = wfMsgHtml( $msg );
579 $attributes = array( 'class' => 'config-label' );
581 $attributes['for'] = $forId;
584 "<div class=\"config-input\">\n" .
587 $labelText ) . "\n" .
593 * Get a labelled text box to configure a variable.
595 * @param $params Array
597 * var: The variable to be configured (required)
598 * label: The message name for the label (required)
599 * attribs: Additional attributes for the input element (optional)
600 * controlName: The name for the input element (optional)
601 * value: The current value of the variable (optional)
603 public function getTextBox( $params ) {
604 if ( !isset( $params['controlName'] ) ) {
605 $params['controlName'] = 'config_' . $params['var'];
607 if ( !isset( $params['value'] ) ) {
608 $params['value'] = $this->getVar( $params['var'] );
610 if ( !isset( $params['attribs'] ) ) {
611 $params['attribs'] = array();
616 $params['controlName'],
618 $params['controlName'],
619 30, // intended to be overridden by CSS
621 $params['attribs'] +
array(
622 'id' => $params['controlName'],
623 'class' => 'config-input-text',
624 'tabindex' => $this->nextTabIndex()
631 * Get a labelled password box to configure a variable.
633 * Implements password hiding
634 * @param $params Array
636 * var: The variable to be configured (required)
637 * label: The message name for the label (required)
638 * attribs: Additional attributes for the input element (optional)
639 * controlName: The name for the input element (optional)
640 * value: The current value of the variable (optional)
642 public function getPasswordBox( $params ) {
643 if ( !isset( $params['value'] ) ) {
644 $params['value'] = $this->getVar( $params['var'] );
646 if ( !isset( $params['attribs'] ) ) {
647 $params['attribs'] = array();
649 $params['value'] = $this->getFakePassword( $params['value'] );
650 $params['attribs']['type'] = 'password';
651 return $this->getTextBox( $params );
655 * Get a labelled checkbox to configure a boolean variable.
657 * @param $params Array
659 * var: The variable to be configured (required)
660 * label: The message name for the label (required)
661 * attribs: Additional attributes for the input element (optional)
662 * controlName: The name for the input element (optional)
663 * value: The current value of the variable (optional)
665 public function getCheckBox( $params ) {
666 if ( !isset( $params['controlName'] ) ) {
667 $params['controlName'] = 'config_' . $params['var'];
669 if ( !isset( $params['value'] ) ) {
670 $params['value'] = $this->getVar( $params['var'] );
672 if ( !isset( $params['attribs'] ) ) {
673 $params['attribs'] = array();
675 if( isset( $params['rawtext'] ) ) {
676 $labelText = $params['rawtext'];
678 $labelText = $this->parse( wfMsg( $params['label'] ) );
681 "<div class=\"config-input-check\">\n" .
684 $params['controlName'],
686 $params['attribs'] +
array(
687 'id' => $params['controlName'],
688 'class' => 'config-input-text',
689 'tabindex' => $this->nextTabIndex(),
698 * Get a set of labelled radio buttons.
700 * @param $params Array
702 * var: The variable to be configured (required)
703 * label: The message name for the label (required)
704 * itemLabelPrefix: The message name prefix for the item labels (required)
705 * values: List of allowed values (required)
706 * itemAttribs Array of attribute arrays, outer key is the value name (optional)
707 * commonAttribs Attribute array applied to all items
708 * controlName: The name for the input element (optional)
709 * value: The current value of the variable (optional)
711 public function getRadioSet( $params ) {
712 if ( !isset( $params['controlName'] ) ) {
713 $params['controlName'] = 'config_' . $params['var'];
715 if ( !isset( $params['value'] ) ) {
716 $params['value'] = $this->getVar( $params['var'] );
718 if ( !isset( $params['label'] ) ) {
721 $label = $this->parse( wfMsgNoTrans( $params['label'] ) );
723 $s = "<label class=\"config-label\">\n" .
726 "<ul class=\"config-settings-block\">\n";
727 foreach ( $params['values'] as $value ) {
728 $itemAttribs = array();
729 if ( isset( $params['commonAttribs'] ) ) {
730 $itemAttribs = $params['commonAttribs'];
732 if ( isset( $params['itemAttribs'][$value] ) ) {
733 $itemAttribs = $params['itemAttribs'][$value] +
$itemAttribs;
735 $checked = $value == $params['value'];
736 $id = $params['controlName'] . '_' . $value;
737 $itemAttribs['id'] = $id;
738 $itemAttribs['tabindex'] = $this->nextTabIndex();
741 Xml
::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
743 Xml
::tags( 'label', array( 'for' => $id ), $this->parse(
744 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) )
753 * Output an error or warning box using a Status object.
755 public function showStatusBox( $status ) {
756 if( !$status->isGood() ) {
757 $text = $status->getWikiText();
758 if( $status->isOk() ) {
759 $box = $this->getWarningBox( $text );
761 $box = $this->getErrorBox( $text );
763 $this->output
->addHTML( $box );
767 public function showStatusMessage( $status ) {
768 $text = $status->getWikiText();
769 $this->output
->addWikiText(
770 "<div class=\"config-message\">\n" .
777 * Convenience function to set variables based on form data.
778 * Assumes that variables containing "password" in the name are (potentially
781 * @param $varNames Array
782 * @param $prefix String: the prefix added to variables to obtain form names
784 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
785 $newValues = array();
786 foreach ( $varNames as $name ) {
787 $value = trim( $this->request
->getVal( $prefix . $name ) );
788 $newValues[$name] = $value;
789 if ( $value === null ) {
791 $this->setVar( $name, false );
793 if ( stripos( $name, 'password' ) !== false ) {
794 $this->setPassword( $name, $value );
796 $this->setVar( $name, $value );
804 * Get the starting tags of a fieldset.
806 * @param $legend String: message name
808 public function getFieldsetStart( $legend ) {
809 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
813 * Get the end tag of a fieldset.
815 public function getFieldsetEnd() {
816 return "</fieldset>\n";
820 * Helper for Installer::docLink()
822 public function getDocUrl( $page ) {
823 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
824 if ( in_array( $this->currentPageName
, $this->pageSequence
) ) {
825 $url .= '&lastPage=' . urlencode( $this->currentPageName
);
831 abstract class WebInstallerPage
{
832 public function __construct( $parent ) {
833 $this->parent
= $parent;
836 public function addHTML( $html ) {
837 $this->parent
->output
->addHTML( $html );
840 public function startForm() {
842 "<div class=\"config-section\">\n" .
847 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
853 public function endForm( $continue = 'continue' ) {
854 $this->parent
->output
->outputWarnings();
855 $s = "<div class=\"config-submit\">\n";
856 $id = $this->getId();
857 if ( $id === false ) {
858 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
861 // Fake submit button for enter keypress
862 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
863 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
866 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
868 'name' => 'submit-back',
869 'tabindex' => $this->parent
->nextTabIndex()
873 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
875 'name' => "submit-$continue",
876 'tabindex' => $this->parent
->nextTabIndex(),
879 $s .= "</div></form></div>\n";
880 $this->addHTML( $s );
883 public function getName() {
884 return str_replace( 'WebInstaller_', '', get_class( $this ) );
887 public function getId() {
888 return array_search( $this->getName(), $this->parent
->pageSequence
);
891 public abstract function execute();
893 public function getVar( $var ) {
894 return $this->parent
->getVar( $var );
897 public function setVar( $name, $value ) {
898 $this->parent
->setVar( $name, $value );
902 class WebInstaller_Language
extends WebInstallerPage
{
905 $r = $this->parent
->request
;
906 $userLang = $r->getVal( 'UserLang' );
907 $contLang = $r->getVal( 'ContLang' );
909 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
911 $lifetime = 1440; // PHP default
914 if ( $r->wasPosted() ) {
916 if ( $this->parent
->getSession( 'test' ) === null ) {
917 $requestTime = $r->getVal( 'LanguageRequestTime' );
918 if ( !$requestTime ) {
919 // The most likely explanation is that the user was knocked back
920 // from another page on POST due to session expiry
921 $msg = 'config-session-expired';
922 } elseif ( time() - $requestTime > $lifetime ) {
923 $msg = 'config-session-expired';
925 $msg = 'config-no-session';
927 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
929 $languages = Language
::getLanguageNames();
930 if ( isset( $languages[$userLang] ) ) {
931 $this->setVar( '_UserLang', $userLang );
933 if ( isset( $languages[$contLang] ) ) {
934 $this->setVar( 'wgLanguageCode', $contLang );
938 } elseif ( $this->parent
->showSessionWarning
) {
939 # The user was knocked back from another page to the start
940 # This probably indicates a session expiry
941 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
944 $this->parent
->setSession( 'test', true );
946 if ( !isset( $languages[$userLang] ) ) {
947 $userLang = $this->getVar( '_UserLang', 'en' );
949 if ( !isset( $languages[$contLang] ) ) {
950 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
954 Xml
::hidden( 'LanguageRequestTime', time() ) .
955 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
956 $this->parent
->getHelpBox( 'config-your-language-help' ) .
957 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
958 $this->parent
->getHelpBox( 'config-wiki-language-help' );
961 $this->addHTML( $s );
966 * Get a <select> for selecting languages
968 function getLanguageSelector( $name, $label, $selectedCode ) {
969 global $wgDummyLanguageCodes;
970 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
972 $languages = Language
::getLanguageNames();
974 $dummies = array_flip( $wgDummyLanguageCodes );
975 foreach ( $languages as $code => $lang ) {
976 if ( isset( $dummies[$code] ) ) continue;
977 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
979 $s .= "\n</select>\n";
980 return $this->parent
->label( $label, $name, $s );
984 class WebInstaller_Welcome
extends WebInstallerPage
{
986 if ( $this->parent
->request
->wasPosted() ) {
987 if ( $this->getVar( '_Environment' ) ) {
991 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
992 $status = $this->parent
->doEnvironmentChecks();
994 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
1001 class WebInstaller_DBConnect
extends WebInstallerPage
{
1002 function execute() {
1003 $r = $this->parent
->request
;
1004 if ( $r->wasPosted() ) {
1005 $status = $this->submit();
1006 if ( $status->isGood() ) {
1007 $this->setVar( '_UpgradeDone', false );
1010 $this->parent
->showStatusBox( $status );
1017 $types = "<ul class=\"config-settings-block\">\n";
1019 $defaultType = $this->getVar( 'wgDBtype' );
1020 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
1021 $installer = $this->parent
->getDBInstaller( $type );
1025 $installer->getReadableName(),
1029 $type == $defaultType,
1030 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
1035 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
1036 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
1037 $installer->getConnectForm() .
1040 $types .= "</ul><br clear=\"left\"/>\n";
1043 $this->parent
->label( 'config-db-type', false, $types ) .
1051 $r = $this->parent
->request
;
1052 $type = $r->getVal( 'DBType' );
1053 $this->setVar( 'wgDBtype', $type );
1054 $installer = $this->parent
->getDBInstaller( $type );
1055 if ( !$installer ) {
1056 return Status
::newFatal( 'config-invalid-db-type' );
1058 return $installer->submitConnectForm();
1062 class WebInstaller_Upgrade
extends WebInstallerPage
{
1063 function execute() {
1064 if ( $this->getVar( '_UpgradeDone' ) ) {
1065 if ( $this->parent
->request
->wasPosted() ) {
1066 // Done message acknowledged
1069 // Back button click
1070 // Show the done message again
1071 // Make them click back again if they want to do the upgrade again
1072 $this->showDoneMessage();
1077 // wgDBtype is generally valid here because otherwise the previous page
1078 // (connect) wouldn't have declared its happiness
1079 $type = $this->getVar( 'wgDBtype' );
1080 $installer = $this->parent
->getDBInstaller( $type );
1082 if ( !$installer->needsUpgrade() ) {
1086 if ( $this->parent
->request
->wasPosted() ) {
1088 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
1089 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
1090 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
1092 $this->parent
->output
->flush();
1093 $result = $installer->doUpgrade();
1094 $this->addHTML( '</textarea>
1095 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
1096 $this->parent
->output
->flush();
1098 $this->setVar( '_UpgradeDone', true );
1099 $this->showDoneMessage();
1105 $this->addHTML( $this->parent
->getInfoBox(
1106 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
1110 function showDoneMessage() {
1113 $this->parent
->getInfoBox(
1114 wfMsgNoTrans( 'config-upgrade-done',
1115 $GLOBALS['wgServer'] .
1116 $this->getVar( 'wgScriptPath' ) . '/index' .
1117 $this->getVar( 'wgScriptExtension' )
1121 $this->endForm( 'regenerate' );
1125 class WebInstaller_DBSettings
extends WebInstallerPage
{
1126 function execute() {
1127 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
1129 $r = $this->parent
->request
;
1130 if ( $r->wasPosted() ) {
1131 $status = $installer->submitSettingsForm();
1132 if ( $status === false ) {
1134 } elseif ( $status->isGood() ) {
1137 $this->parent
->showStatusBox( $status );
1141 $form = $installer->getSettingsForm();
1142 if ( $form === false ) {
1147 $this->addHTML( $form );
1153 class WebInstaller_Name
extends WebInstallerPage
{
1154 function execute() {
1155 $r = $this->parent
->request
;
1156 if ( $r->wasPosted() ) {
1157 if ( $this->submit() ) {
1164 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
1165 $this->setVar( 'wgSitename', '' );
1168 // Set wgMetaNamespace to something valid before we show the form.
1169 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
1170 $metaNS = $this->getVar( 'wgMetaNamespace' );
1171 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
1174 $this->parent
->getTextBox( array(
1175 'var' => 'wgSitename',
1176 'label' => 'config-site-name',
1178 $this->parent
->getHelpBox( 'config-site-name-help' ) .
1179 $this->parent
->getRadioSet( array(
1180 'var' => '_NamespaceType',
1181 'label' => 'config-project-namespace',
1182 'itemLabelPrefix' => 'config-ns-',
1183 'values' => array( 'site-name', 'generic', 'other' ),
1184 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
1186 $this->parent
->getTextBox( array(
1187 'var' => 'wgMetaNamespace',
1189 'attribs' => array( 'disabled' => '' ),
1191 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
1192 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
1193 $this->parent
->getTextBox( array(
1194 'var' => '_AdminName',
1195 'label' => 'config-admin-name'
1197 $this->parent
->getPasswordBox( array(
1198 'var' => '_AdminPassword',
1199 'label' => 'config-admin-password',
1201 $this->parent
->getPasswordBox( array(
1202 'var' => '_AdminPassword2',
1203 'label' => 'config-admin-password-confirm'
1205 $this->parent
->getHelpBox( 'config-admin-help' ) .
1206 $this->parent
->getTextBox( array(
1207 'var' => '_AdminEmail',
1208 'label' => 'config-admin-email'
1210 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
1211 $this->parent
->getCheckBox( array(
1212 'var' => '_Subscribe',
1213 'label' => 'config-subscribe'
1215 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
1216 $this->parent
->getFieldsetEnd() .
1217 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
1218 $this->parent
->getRadioSet( array(
1219 'var' => '_SkipOptional',
1220 'itemLabelPrefix' => 'config-optional-',
1221 'values' => array( 'continue', 'skip' )
1225 // Restore the default value
1226 $this->setVar( 'wgMetaNamespace', $metaNS );
1234 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
1235 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
1236 '_Subscribe', '_SkipOptional' ) );
1238 // Validate site name
1239 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
1240 $this->parent
->showError( 'config-site-name-blank' );
1245 $nsType = $this->getVar( '_NamespaceType' );
1246 if ( $nsType == 'site-name' ) {
1247 $name = $this->getVar( 'wgSitename' );
1248 // Sanitize for namespace
1249 // This algorithm should match the JS one in WebInstallerOutput.php
1250 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
1251 $name = str_replace( '&', '&', $name );
1252 $name = preg_replace( '/__+/', '_', $name );
1253 $name = ucfirst( trim( $name, '_' ) );
1254 } elseif ( $nsType == 'generic' ) {
1255 $name = wfMsg( 'config-ns-generic' );
1257 $name = $this->getVar( 'wgMetaNamespace' );
1260 // Validate namespace
1261 if ( strpos( $name, ':' ) !== false ) {
1264 // Title-style validation
1265 $title = Title
::newFromText( $name );
1267 $good = $nsType == 'site-name' ?
true : false;
1269 $name = $title->getDBkey();
1274 $this->parent
->showError( 'config-ns-invalid', $name );
1277 $this->setVar( 'wgMetaNamespace', $name );
1279 // Validate username for creation
1280 $name = $this->getVar( '_AdminName' );
1281 if ( strval( $name ) === '' ) {
1282 $this->parent
->showError( 'config-admin-name-blank' );
1286 $cname = User
::getCanonicalName( $name, 'creatable' );
1287 if ( $cname === false ) {
1288 $this->parent
->showError( 'config-admin-name-invalid', $name );
1291 $this->setVar( '_AdminName', $cname );
1295 // Validate password
1297 $pwd = $this->getVar( '_AdminPassword' );
1298 $user = User
::newFromName( $cname );
1299 $valid = $user->getPasswordValidity( $pwd );
1300 if ( strval( $pwd ) === '' ) {
1301 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
1302 # This message is more specific and helpful.
1303 $msg = 'config-admin-password-blank';
1304 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
1305 $msg = 'config-admin-password-mismatch';
1306 } elseif ( $valid !== true ) {
1307 # As of writing this will only catch the username being e.g. 'FOO' and
1308 # the password 'foo'
1311 if ( $msg !== false ) {
1312 $this->parent
->showError( $msg );
1313 $this->setVar( '_AdminPassword', '' );
1314 $this->setVar( '_AdminPassword2', '' );
1321 class WebInstaller_Options
extends WebInstallerPage
{
1322 function execute() {
1323 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
1326 if ( $this->parent
->request
->wasPosted() ) {
1327 if ( $this->submit() ) {
1335 $this->parent
->getRadioSet( array(
1336 'var' => '_RightsProfile',
1337 'label' => 'config-profile',
1338 'itemLabelPrefix' => 'config-profile-',
1339 'values' => array_keys( $this->parent
->rightsProfiles
),
1341 $this->parent
->getHelpBox( 'config-profile-help' ) .
1344 $this->parent
->getRadioSet( array(
1345 'var' => '_LicenseCode',
1346 'label' => 'config-license',
1347 'itemLabelPrefix' => 'config-license-',
1348 'values' => array_keys( $this->parent
->licenses
),
1349 'commonAttribs' => array( 'class' => 'licenseRadio' ),
1351 $this->getCCChooser() .
1352 $this->parent
->getHelpBox( 'config-license-help' ) .
1355 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
1356 $this->parent
->getCheckBox( array(
1357 'var' => 'wgEnableEmail',
1358 'label' => 'config-enable-email',
1359 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
1361 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
1362 "<div id=\"emailwrapper\">" .
1363 $this->parent
->getTextBox( array(
1364 'var' => 'wgPasswordSender',
1365 'label' => 'config-email-sender'
1367 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
1368 $this->parent
->getCheckBox( array(
1369 'var' => 'wgEnableUserEmail',
1370 'label' => 'config-email-user',
1372 $this->parent
->getHelpBox( 'config-email-user-help' ) .
1373 $this->parent
->getCheckBox( array(
1374 'var' => 'wgEnotifUserTalk',
1375 'label' => 'config-email-usertalk',
1377 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
1378 $this->parent
->getCheckBox( array(
1379 'var' => 'wgEnotifWatchlist',
1380 'label' => 'config-email-watchlist',
1382 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
1383 $this->parent
->getCheckBox( array(
1384 'var' => 'wgEmailAuthentication',
1385 'label' => 'config-email-auth',
1387 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
1389 $this->parent
->getFieldsetEnd()
1392 $extensions = $this->parent
->findExtensions();
1394 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
1395 foreach( array_keys($extensions) as $ext ) {
1396 $extHtml .= $this->parent
->getCheckBox( array(
1397 'var' => "ext-$ext",
1401 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
1402 $this->parent
->getFieldsetEnd();
1403 $this->addHTML( $extHtml );
1408 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
1409 $this->parent
->getCheckBox( array(
1410 'var' => 'wgEnableUploads',
1411 'label' => 'config-upload-enable',
1412 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
1414 $this->parent
->getHelpBox( 'config-upload-help' ) .
1415 '<div id="uploadwrapper" style="display: none;">' .
1416 $this->parent
->getTextBox( array(
1417 'var' => 'wgDeletedDirectory',
1418 'label' => 'config-upload-deleted',
1420 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
1422 $this->parent
->getTextBox( array(
1424 'label' => 'config-logo'
1426 $this->parent
->getHelpBox( 'config-logo-help' )
1428 $canUse = $this->getVar( '_ExternalHTTP' ) ?
1429 'config-instantcommons-good' : 'config-instantcommons-bad';
1431 $this->parent
->getCheckBox( array(
1432 'var' => 'wgUseInstantCommons',
1433 'label' => 'config-instantcommons',
1435 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
1436 $this->parent
->getFieldsetEnd()
1439 $caches = array( 'none' );
1440 if( count( $this->getVar( '_Caches' ) ) ) {
1441 $caches[] = 'accel';
1443 $caches[] = 'memcached';
1447 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
1448 # Object cache settings
1449 $this->parent
->getRadioSet( array(
1450 'var' => 'wgMainCacheType',
1451 'label' => 'config-cache-options',
1452 'itemLabelPrefix' => 'config-cache-',
1453 'values' => $caches,
1456 $this->parent
->getHelpBox( 'config-cache-help' ) .
1457 '<div id="config-memcachewrapper">' .
1458 $this->parent
->getTextBox( array(
1459 'var' => '_MemCachedServers',
1460 'label' => 'config-memcached-servers',
1462 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
1463 $this->parent
->getFieldsetEnd()
1468 function getCCPartnerUrl() {
1470 $exitUrl = $wgServer . $this->parent
->getUrl( array(
1471 'page' => 'Options',
1472 'SubmitCC' => 'indeed',
1473 'config__LicenseCode' => 'cc',
1474 'config_wgRightsUrl' => '[license_url]',
1475 'config_wgRightsText' => '[license_name]',
1476 'config_wgRightsIcon' => '[license_button]',
1478 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
1479 '/skins/common/config-cc.css';
1480 $iframeUrl = 'http://creativecommons.org/license/?' .
1481 wfArrayToCGI( array(
1482 'partner' => 'MediaWiki',
1483 'exit_url' => $exitUrl,
1484 'lang' => $this->getVar( '_UserLang' ),
1485 'stylesheet' => $styleUrl,
1490 function getCCChooser() {
1491 $iframeAttribs = array(
1492 'class' => 'config-cc-iframe',
1493 'name' => 'config-cc-iframe',
1494 'id' => 'config-cc-iframe',
1499 if ( $this->getVar( '_CCDone' ) ) {
1500 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
1502 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1506 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
1507 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1511 function getCCDoneBox() {
1512 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1513 // If you change this height, also change it in config.css
1514 $expandJs = str_replace( '$1', '54em', $js );
1515 $reduceJs = str_replace( '$1', '70px', $js );
1518 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1520 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1522 "<p style=\"text-align: center\">" .
1525 'href' => $this->getCCPartnerUrl(),
1526 'onclick' => $expandJs,
1528 wfMsg( 'config-cc-again' )
1531 "<script type=\"text/javascript\">\n" .
1532 # Reduce the wrapper div height
1533 htmlspecialchars( $reduceJs ) .
1539 function submitCC() {
1540 $newValues = $this->parent
->setVarsFromRequest(
1541 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1542 if ( count( $newValues ) != 3 ) {
1543 $this->parent
->showError( 'config-cc-error' );
1546 $this->setVar( '_CCDone', true );
1547 $this->addHTML( $this->getCCDoneBox() );
1551 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1552 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
1553 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1554 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
1555 'wgUseInstantCommons' ) );
1557 if ( !in_array( $this->getVar( '_RightsProfile' ),
1558 array_keys( $this->parent
->rightsProfiles
) ) )
1560 reset( $this->parent
->rightsProfiles
);
1561 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
1564 $code = $this->getVar( '_LicenseCode' );
1565 if ( $code == 'cc-choose' ) {
1566 if ( !$this->getVar( '_CCDone' ) ) {
1567 $this->parent
->showError( 'config-cc-not-chosen' );
1570 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
1571 $entry = $this->parent
->licenses
[$code];
1572 if ( isset( $entry['text'] ) ) {
1573 $this->setVar( 'wgRightsText', $entry['text'] );
1575 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
1577 $this->setVar( 'wgRightsUrl', $entry['url'] );
1578 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1580 $this->setVar( 'wgRightsText', '' );
1581 $this->setVar( 'wgRightsUrl', '' );
1582 $this->setVar( 'wgRightsIcon', '' );
1585 $exts = $this->parent
->getVar( '_Extensions' );
1586 foreach( $exts as $key => $ext ) {
1587 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
1588 unset( $exts[$key] );
1591 $this->parent
->setVar( '_Extensions', $exts );
1596 class WebInstaller_Install
extends WebInstallerPage
{
1598 function execute() {
1599 if( $this->parent
->request
->wasPosted() ) {
1601 } elseif( $this->getVar( '_InstallDone' ) ) {
1603 $status = new Status();
1604 $status->warning( 'config-install-alreadydone' );
1605 $this->parent
->showStatusBox( $status );
1608 $this->addHTML("<ul>");
1609 $this->parent
->performInstallation(
1610 array( $this, 'startStage'),
1611 array( $this, 'endStage' )
1613 $this->addHTML("</ul>");
1619 public function startStage( $step ) {
1620 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
1623 public function endStage( $step, $status ) {
1624 $success = $status->isGood();
1625 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
1626 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
1628 $html = "<span class=\"error\">$html</span>";
1630 $this->addHTML( $html . "</li>\n" );
1632 $this->parent
->showStatusBox( $status );
1637 class WebInstaller_Complete
extends WebInstallerPage
{
1638 public function execute() {
1642 $this->parent
->getInfoBox(
1643 wfMsgNoTrans( 'config-install-done',
1644 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
1645 $GLOBALS['wgServer'] .
1646 $this->getVar( 'wgScriptPath' ) . '/index' .
1647 $this->getVar( 'wgScriptExtension' )
1651 $this->endForm( false );
1655 class WebInstaller_Restart
extends WebInstallerPage
{
1656 function execute() {
1657 $r = $this->parent
->request
;
1658 if ( $r->wasPosted() ) {
1659 $really = $r->getVal( 'submit-restart' );
1661 $this->parent
->session
= array();
1662 $this->parent
->happyPages
= array();
1663 $this->parent
->settings
= array();
1669 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
1670 $this->addHTML( $s );
1671 $this->endForm( 'restart' );
1675 abstract class WebInstaller_Document
extends WebInstallerPage
{
1676 abstract function getFileName();
1678 function execute() {
1679 $text = $this->getFileContents();
1680 $this->parent
->output
->addWikiText( $text );
1682 $this->endForm( false );
1685 function getFileContents() {
1686 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
1689 protected function formatTextFile( $text ) {
1690 $text = str_replace( array( '<', '{{', '[[' ),
1691 array( '<', '{{', '[[' ), $text );
1692 // replace numbering with [1], [2], etc with MW-style numbering
1693 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
1694 // join word-wrapped lines into one
1697 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1698 } while ( $text != $prev );
1699 // turn (bug nnnn) into links
1700 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1701 // add links to manual to every global variable mentioned
1702 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1703 // special case for <pre> - formatted links
1706 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
1707 } while ( $text != $prev );
1711 private function replaceBugLinks( $matches ) {
1712 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1713 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1716 private function replaceConfigLinks( $matches ) {
1717 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1718 $matches[1] . ' ' . $matches[1] . ']</span>';
1722 class WebInstaller_Readme
extends WebInstaller_Document
{
1723 function getFileName() { return 'README'; }
1725 function getFileContents() {
1726 return $this->formatTextFile( parent
::getFileContents() );
1730 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1731 function getFileName() { return 'RELEASE-NOTES'; }
1733 function getFileContents() {
1734 return $this->formatTextFile( parent
::getFileContents() );
1738 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1739 function getFileName() { return 'UPGRADE'; }
1741 function getFileContents() {
1742 return $this->formatTextFile( parent
::getFileContents() );
1746 class WebInstaller_Copying
extends WebInstaller_Document
{
1747 function getFileName() { return 'COPYING'; }
1749 function getFileContents() {
1750 $text = parent
::getFileContents();
1751 $text = str_replace( "\x0C", '', $text );
1752 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
1753 $text = '<tt>' . nl2br( $text ) . '</tt>';
1757 private static function replaceLeadingSpaces( $matches ) {
1758 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );